package com.atguigu.spzx.manager.service.impl;

import com.atguigu.spzx.manager.mapper.ProductSpecMapper;
import com.atguigu.spzx.manager.service.ProductSpecService;
import com.atguigu.spzx.model.entity.product.ProductSpec;
import com.atguigu.spzx.model.vo.common.Result;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PostMapping;

import java.util.List;

@Service
public class ProductSpecServiceImpl implements ProductSpecService {
    @Autowired
    private ProductSpecMapper productSpecMapper;

    @Override
    public PageInfo<ProductSpec> getProductSpecPageList(Integer page, Integer limit) {
        //开启分页查询
        PageHelper.startPage(page,limit);
        List<ProductSpec> productSpecList=productSpecMapper.getProductSpecPageList();
        PageInfo<ProductSpec> pageInfo=new PageInfo<>(productSpecList);
        return pageInfo;
    }

    @Override
    public void save(ProductSpec productSpec) {
        productSpecMapper.insertProductSpec(productSpec);
    }

    @Override
    public void updateById(ProductSpec productSpec) {
        productSpecMapper.updateById(productSpec);
    }

    @Override
    public void deleteById(Long id) {
        productSpecMapper.deleteById(id);
    }

    @Override
    public List<ProductSpec> findAllProductSpec() {
        List<ProductSpec> productSpecList = productSpecMapper.selectAllProductSpec();
        return productSpecList;
    }


}
